package com.kerbores.kop.module.service.demo;

import java.io.File;

import org.nutz.mvc.annotation.AdaptBy;
import org.nutz.mvc.annotation.At;
import org.nutz.mvc.annotation.Param;
import org.nutz.mvc.upload.UploadAdaptor;

import com.kerbores.kop.common.BaseServiceModule;
import com.kerbores.utils.entries.Result;

@At("/kop")
public class DemoService extends BaseServiceModule {

	@At
	/**
	 * 
	 * @param a
	 * @param b
	 * @param c
	 * @return
	 */
	public Result demo(@Param("a") int a, @Param("b") int b, @Param("c") int c) {
		return _checkAppKey() ? Result.success().addData("result", a + b + c) : Result.fail("appKey不正确");
	}

	@At
	@AdaptBy(type = UploadAdaptor.class, args = { "${app.root}/WEB-INF/tmp" })
	public Result fileUpload(@Param("photo") File f, @Param("a") int a, @Param("b") int b) {
		return Result.success().addData("length", f.length()).addData("a", a).addData("b", b);
	}
}
